#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int arr1[1001] = { 0 };
    int arr2[1001] = { 0 };
    int arr3[2002] = { 0 };
    int i = 0, j = 0, k = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (j = 0; j < m; j++)
    {
        scanf("%d", &arr2[j]);
    }
    i = j = 0;
    while (i < n && j < m)
    {
        if (arr1[i] < arr2[j])
        {
            arr3[k++] = arr1[i++];
        }
        else
        {
            arr3[k++] = arr2[j++];
        }
    }
    if (i == n)
    {
        for (; j < m; j++)
        {
            arr3[k++] = arr2[j];
        }
    }
    else
    {
        for (; i < n; i++)
        {
            arr3[k++] = arr1[i];
        }
    }
    for (i = 0; i < m + n; i++)
    {
        printf("%d ", arr3[i]);
    }
    return 0;
}